package Exercise;

import java.util.Arrays;
import java.util.Comparator;
import java.util.Random;

class AbsComparator implements Comparator { 
    public int compare(Object o1, Object o2) 
    { int v1 = Math.abs(((Integer)o1).intValue()); 
        int v2 = Math.abs(((Integer)o2).intValue()); 
        return v1 > v2 ? 1 : (v1 == v2 ? 0 : -1);
     } 
    }
public class com {
    public static void main(String[] args) { 
        Random random = new Random(); 
        Integer[] integers = new Integer[20]; 
        for(int i = 0; i < integers.length; i++) 
        { 
            integers[i] = new Integer( random.nextInt(100) *( random.nextBoolean() ? 1 : -1) );
        }
        Arrays.sort(integers);
        Arrays.sort(integers, new AbsComparator());
        Integer[] arr1={1,2,5,-2,3};
        Arrays.sort(arr1,(Integer a,Integer b)->{return b-a;});
        System.out.println(Arrays.toString(arr1));
        
    }
}
